package com.open.capacity.service.impl;

import com.open.capacity.common.entity.PlaceModel;
import com.open.capacity.common.model.PageModel;
import com.open.capacity.mapper.PlaceMapper;
import com.open.capacity.service.PlaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PlaceServiceImpl implements PlaceService {
    @Autowired
    private PlaceMapper placeMapper;


    @Override
    public List<PlaceModel> findStar() {
        List<PlaceModel> start = placeMapper.findStart();
        if (start.size()>3){
            for (int i = 4; i <start.size() ; i++) {
                start.remove(4);
            }
        }
        return start;
    }

    @Override
    public List<PlaceModel> findAll(PlaceModel placeModel) {
        PageModel pageModel=new PageModel();
        pageModel.setCurPage((placeModel.getPage()-1)*placeModel.getLimit());
        pageModel.setPageSize(placeModel.getLimit());
        return placeMapper.findAll(placeModel,pageModel);
    }

    @Override
    public List<PlaceModel> findById(PlaceModel placeModel) {
        return placeMapper.findById(placeModel);

    }

    @Override
    public Integer count(PlaceModel placeModel) {
        return placeMapper.count(placeModel);
    }


}
